Replace the heuristic lookup of Cairo variables with a semantic walk in FunctionDebugInfo#9992
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
755d61f to
bda4cf2
Compare
2e1fbb0 to
481558b
Compare
PR SummaryMedium Risk Overview
Large blocks of syntax-tree identifier lookup and lookup-item resolution are removed in favor of this structured traversal. Reviewed by Cursor Bugbot for commit a0d63ce. Bugbot is set up for automated code reviews on this repo. Configure here. |
bda4cf2 to
abd9ac1
Compare
4d24288 to
f684aea
Compare
abd9ac1 to
142b89f
Compare
f684aea to
610632e
Compare
| } | ||
| let rhs_ty = self.db.expr_semantic(self.function_with_body_id, let_stmt.expr).ty(); | ||
| let rhs_var = self.resolve_rhs_sierra_var(let_stmt.expr, rhs_ty); | ||
| self.bind_pattern(let_stmt.pattern, rhs_var); |
There was a problem hiding this comment.
Let-else else mutates aliases early
Medium Severity
For Statement::Let with a let-else clause, the walker visits the else expression before it resolves the RHS Sierra variable and binds the pattern. Because resolve_rhs_sierra_var uses the live alias_map, any rebindings performed while visiting the else branch can change how the main let RHS is resolved, producing incorrect Sierra-to-Cairo mappings on the success path.
Reviewed by Cursor Bugbot for commit 610632e. Configure here.
142b89f to
0890266
Compare
… `FunctionDebugInfo`
610632e to
a0d63ce
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
There are 3 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a0d63ce. Configure here.
| self.bind_pattern(pattern_id, scrutinee_sierra.clone()); | ||
| } | ||
| self.visit_expr(arm.expression); | ||
| } |
There was a problem hiding this comment.
Control flow merges alias state
Medium Severity
BindingCollector keeps one global alias_map while visiting every if branch and every match arm in order. Later branches overwrite earlier bindings, so code after control flow (and later arms) resolves Cairo variables using the last visited branch’s Sierra slots, not the branch that would run at runtime.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit a0d63ce. Configure here.
| self.bind_pattern(for_expr.pattern, None); | ||
| self.visit_expr(for_expr.body); | ||
| } | ||
| Expr::Loop(loop_expr) => self.visit_expr(loop_expr.body), |
There was a problem hiding this comment.
Loop body walked once
Medium Severity
Expr::Loop and Expr::While call visit_expr on the body a single time, so each reassignment inside the loop produces at most one rebind event. Sierra variables allocated on later iterations at the same source locations are never added to bindings, leaving many loop-live slots without Cairo names.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit a0d63ce. Configure here.
0890266 to
caca9d7
Compare


Summary
This PR reworks the Sierra -> Cairo variable reconstruction logic.
Instead of a heuristic lookup, we perform a top-down walk through the function's semantic model and construct the mapping by hand, using a dedicated logic for every type of statement and expression.
This allows to handle all problematic cases of Cairo variables, like re-binds or loops.
Type of change
Please check one:
Why is this change needed?
It allows the Cairo debugger to properly handle variables in general and support loops.
What was the behavior or documentation before?
What is the behavior or documentation after?
Related issue or discussion (if any)
Additional context